﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using AnguaRPGEngine.Library.Packages;
using System.Runtime.InteropServices;
using System.Drawing;

namespace AnguaRPGEngine.Library.Systems
{
    public class Tools
    {
        [DllImport("user32.dll")]
        public static extern bool GetCursorPos(ref Point lpPoint);        
        
        public static string ConvertEnumToString(string EnumString)
        {
            return EnumString.Replace("__", "-").Replace("_", " ");
        }
        public static string GetMessageFromPackage(string package)
        {
            string pkg = package.Remove(0, Constants.StartOfPacket.Length);
            pkg = pkg.Remove(pkg.Length - Constants.EndOfPacket.Length, Constants.EndOfPacket.Length);
            return pkg;
        }
        public static string GetStringFromPackage(byte[] package, int length)
        {
            return Encoding.ASCII.GetString(package, 0, length);
        }
        public static byte[] CreatePackage(int command, string serializedObject)
        {
            string package = string.Format("{0}{1}={2}{3}", Constants.StartOfPacket, command, serializedObject, Constants.EndOfPacket);
            return Encoding.ASCII.GetBytes(package);
        }
        public static bool IsCompletePackage(string package)
        {
            int posStart = package.IndexOf(Constants.StartOfPacket);
            int posEnd = package.IndexOf(Constants.EndOfPacket);
            return (posStart > -1 && posEnd > posStart);
        }
        
    }
}
